import os
import csv

# Set the directory containing the CSV files
directory = './search-result'
csv_files = [filename for filename in os.listdir(
    directory) if filename.endswith('.csv')]
# Sort the list of CSV files alphabetically
csv_files.sort()

# Loop through each file in the directory
for filename in csv_files:
    # Open the file and read its contents
    with open(os.path.join(directory, filename)) as csvfile:
        max_row = []  # initialize max_row to an empty list
        max_val = float('-inf')  # initialize max_val to negative infinity
        reader = csv.reader(csvfile)
        next(reader)  # skip the header row
        for row in reader:
            if len(row) == 0:
                continue
            # get the last column value as a float
            last_col_val = float(row[2])
            last_col_val = last_col_val if last_col_val > 0 else -last_col_val
            if last_col_val > max_val and last_col_val != 1:
                max_val = last_col_val
                max_row = row

        print(f"{filename} : {max_row}")
